<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box{
      width: 300px;
      height: 300px;
      background-color: red;
      margin: 200px auto;
      transform: translate(0);
    }
    /* 设置了固定定位的元素, 默认参考的是浏览器窗口,
      如果设置了固定定位的元素的祖先元素设置了transform属性, 这个固定定位的元素参考父元素
    */
    .inner {
      position: fixed;
      left: 0;
      top: 0;
      width: 100px;
      height: 100px;
      background-color: green;
    }
  </style>
</head>
<body>
  <div class="box">
    <div class="inner"></div>
  </div>
</body>
</html>